﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;

namespace PonGun
{
    public class OptionsScreen : Screen
    {
        List<Button> Buttons = new List<Button>();

        public OptionsScreen(Game1 game, GSM gsm)
            : base(game, gsm)
        {
            Buttons.Add(new Button(Game, GSM, "Textures/Buttons/Back", "Textures/Buttons/BackOver", "Textures/Buttons/BackClicked")
            {
                Name = "Back",
                Position = new Vector2(Game1.RenderArea.Width - 128, Game1.RenderArea.Height - 48),
                OnMousePointerClicked = ButtonClicked  
            });

            Buttons.Add(new Button(Game, GSM, "Textures/Buttons/Easy", "Textures/Buttons/EasyOver", "Textures/Buttons/EasyClicked")
            {
                Name = "Easy",
                Position = new Vector2(Game1.RenderAreaCenter.X , Game1.RenderAreaCenter.Y - 64),
                OnMousePointerClicked = ButtonClicked
            });

            Buttons.Add(new Button(Game, GSM, "Textures/Buttons/Normal", "Textures/Buttons/NormalOver", "Textures/Buttons/NormalClicked")
            {
                Name = "Normal",
                Position = new Vector2(Game1.RenderAreaCenter.X, Game1.RenderAreaCenter.Y + 32),
                OnMousePointerClicked = ButtonClicked
            });

            Buttons.Add(new Button(Game, GSM, "Textures/Buttons/Hard", "Textures/Buttons/HardOver", "Textures/Buttons/HardClicked")
            {
                Name = "Hard",
                Position = new Vector2(Game1.RenderAreaCenter.X, Game1.RenderAreaCenter.Y + 128),
                OnMousePointerClicked = ButtonClicked
            });
        }

        public void ButtonClicked(object sender)
        {
            if (opacity < .5f)
                return;

            switch (((Button)sender).Name)
            {
                case "Back":
                    GSM.NavigateTo("MenuScreen");
                    break;
                case "Easy":
                case "Normal":
                case "Hard":
                    Game.Difficulty = ((Button)sender).Name;
                    Game.ReSetGame();
                    break;
            }
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            foreach (Button b in Buttons)
                b.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);


            foreach (Button b in Buttons)
            {
                b.Draw(gameTime);

                if (Game.Difficulty == b.Name)
                    Game.DrawRectangle(b.Bounds, Color.LimeGreen);
            }
        }
    }
}
